﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}



@*<div class="topPanel">
        <div class="toolbar">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
            </div>
            <div class="btn-group">
                <a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新增股道</a>
            </div>
            <div class="operate">

            </div>
            <script>$('.toolbar').authorizeButton()</script>
        </div>
        <div class="search">
            <table>
                <tr>
                    <td>
                        <div class="input-group" style="padding-left:11px;padding-right:10px;">

                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>*@
<style>
    table tr td {
        padding-left: 15px;
    }

    table tbody tr td {
        height: 20px;
    }

    .form-control {
        display: block;
        /*width: 100%;*/
        /*height: 34px;*/
        width: 53px;
        height: 20px;
        font-size: 10px;
        text-align: center;
        line-height: 1.42857;
        color: rgb(85, 85, 85);
        background-color: rgb(255, 255, 255);
        background-image: none;
        box-shadow: rgba(0, 0, 0, 0.075) 0px 1px 1px inset;
        padding: 8px 19.5px;
        border-width: 1px;
        border-style: solid;
        border-color: rgb(221, 221, 221);
        border-image: initial;
        border-radius: 4px;
        transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
    }
</style>
<div class="gridPanel">

    <table id="gridList" class="table table-bordered table-hover">
        <thead>
            <tr>
                <th style="text-align:center">数量</th>
                <th style="text-align:center">车号</th>
                <th style="text-align:center">操作</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <input type="text" class="form-control " value="1">
                </td>
                <td>
                    <input type="text" class="form-control chehao" value="">
                </td>
                <td>
                    <input type="button" class="form-control addnewlen" value="添加一行" />
                </td>
            </tr>
        </tbody>
    </table>
    <div id="gridPager" style="text-align: center; display: block;">
        <input type="button" class="form-control addnewlen" value="添加一行" style="float: left;margin-left:5px" />
        <input type="button" class="form-control" id="submitId" value="确认删除" onclick="SubmitThisInfo();" style="float: left;margin-left:20px" />
    </div>
</div>
<script src="~/Content/js/guangbiao/GuangBiaoMove.js"></script>
<script>
    //鼠标移动上下左右换行
    tabTableInput("gridList", "text");

    var keyValue = decodeURI($.request("keyValue"));
    //alert(keyValue);
    var newJYDDIndex = 1;
   
    var listobj;
    var optionstr = '';
    
    var pinminglist;
    var pinmingliststr='';
   
    var kehulist;
    var kehuliststr = '';
    $(function() {
        var reg = new RegExp('&quot;', "g")
       
      
        //listobj = JSON.parse(gudaolist);
        //$.each(listobj, function (i) {
        //    if (listobj[i].Name == keyValue) {
        //        optionstr += "<option value='" + listobj[i].F_Id + "'>" + listobj[i].Name + "</option>";
        //    }
        //});
        //pinminglist = JSON.parse(pingming);
        //$.each(pinminglist, function (i) {
        //    pinmingliststr += "<option value='" + pinminglist[i].Name + "'>" + pinminglist[i].Name + "</option>";
        //});
        //kehulist = JSON.parse(kehu);
        //$.each(kehulist, function (i) {
        //    kehuliststr += "<option value='" + kehulist[i].Name + "'>" + kehulist[i].Name + "</option>";
        //});
        //$(".gudao").append(optionstr);
        //$(".pingming").append(pinmingliststr);
        //$(".kehu").append(kehuliststr);
        $(".addnewlen").click(function () {
            //var pingmingselect = $("#gridList tbody").children().last().find(".pingming").val();
          
            //var kehuselect = $("#gridList tbody").children().last().find(".kehu").val();
            //pinmingliststr = '';
            //pinminglist = JSON.parse(pingming);
            //$.each(pinminglist, function (i) {
            //    if (pingmingselect == pinminglist[i].Name) {
            //        pinmingliststr += "<option value='" + pinminglist[i].Name + "' selected = \"selected\">" + pinminglist[i].Name + "</option>";
            //    } else {
            //        pinmingliststr += "<option value='" + pinminglist[i].Name + "'>" + pinminglist[i].Name + "</option>";
            //    }
            //});
            //kehuliststr = '';
            //kehulist = JSON.parse(kehu);
            //$.each(kehulist, function (i) {
            //    if (kehuselect == kehulist[i].Name) {
            //        kehuliststr += "<option value='" + kehulist[i].Name + "' selected = \"selected\" >" + kehulist[i].Name + "</option>";
            //    } else {
            //        kehuliststr += "<option value='" + kehulist[i].Name + "'>" + kehulist[i].Name + "</option>";
            //    }
            //});
            newJYDDIndex += 1;
            $("#gridList tbody").append(
                '<tr>  <td><input type="text" class="form-control xuhao"value="' +
                newJYDDIndex +
                '" > </td>  ' +
                '<td> <input type="text" class="form-control chehao"value="" ></td>' +
                '<td> <input type="button" class="form-control" value="删除当前行"  onclick=\'deleteTr(this);\'/> </td></tr>');
            //每次添加一行数据调用这个方法
            tabTableInput("gridList", "text");
        });

    });

    function deleteTr(nowTr) {
        $(nowTr).parent().parent().remove();
        newJYDDIndex = newJYDDIndex - 1;
    }

    function SubmitThisInfo() {
        $("#submitId").attr("disabled", "disabled");
        var arr = [];
        var trs = $("#gridList tbody tr");
        if (trs.length <= 0) {
            top.alert("请添加数据", function (i) {
                top.close(i);
            });
            return false;
        }
        var flag = 0;
        trs.each(function () {
            debugger;
            var obj = {};
            obj.chehao = $.trim($(this).find(".chehao").val());
           
            if (!$.trim(obj.chehao)) {
                flag = 2;
                return false;
            }
            arr.push(obj);
        });
        switch (flag) {
        case 2:
            top.alert("传入数据为空", function (i) {
                top.close(i);
            });
                $("#submitId").attr("disabled", false);
            return false;
            break;
        }
        $.ajax({
            url: '/Project/PickCar/DelGudaoCar',
            data: { jsonData: JSON.stringify(arr) },
            dataType: "text",
            type: "POST",
            success: function (data) {
                var dataobj = JSON.parse(data);
                if (dataobj.code == 0) {
                    top.alert("删除成功", function (i) {
                    });
                    $("#submitId").attr("disabled", false);
                    $.modalClose();
                }
                else {
                    top.alert(dataobj.msg, function (i) {
                        $("#submitId").attr("disabled", false);
                        layer.close(i);
                    });
                }
            }
        });
    }
</script>